<% if session[:user] != nil and session[:user].authority == "admin" %>
	<h1>Listing users</h1>

	<table>
	  <tr>
		<th>Email</th>
		<th>First Name</th>
		<th>Last Name</th>
	  </tr>

	<% @users.each do |user| %>
	  <tr>
		<td><%= user.email %></td>
		<td><%= user.first_name %></td>
		<td><%= user.last_name %></td>
		
		<td><%= link_to 'Show', user %></td>
		<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
		
	  </tr>
	<% end %>
	</table>
	
<% else %>
	<% if session[:user] != nil and session[:user].authority == "manager" %>
	
		<table>
	  <tr>
		<th>Email</th>
		<th>First Name</th>
		<th>Last Name</th>
	  </tr>

	<% @users.each do |user| %>
	  <% if user.authority != "admin"%>
		  <tr>
			<td><%= user.email %></td>
			<td><%= user.first_name %></td>
			<td><%= user.last_name %></td>
			
			<td><%= link_to 'Show', user %></td>
			<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
			
		  </tr>
	  <% end %>
	<% end %>
	</table>
	
	
	<% else %>
	
	<p>YOU ARE NOT AUTHORIZED TO SEE THIS PAGE :( </p>
	
	<% end %>

<% end %>

<br />
<br>
